package com.frogs.ucenter.v1.request;

import javax.servlet.http.HttpServletRequest;

import com.frogs.framework.util.StringUtil;
import com.frogs.framework.web.HttpRequestInfo;
import com.frogs.system.util.ApiUrlParamEnum;
import com.frogs.system.util.ApplicablePlatformEnum;
import com.frogs.system.util.PromotionApplicablePlatformEnum;
import com.frogs.system.web.api.request.Request;
import com.frogs.system.web.exception.RequestIllegalException;

public class UserShoppingCartSumRequest extends Request {
	
	private int userId ;

	private int applicablePlatformId;
	
	private String userTraceId;
	
	private int subApplicablePlatformId = PromotionApplicablePlatformEnum.NEW_MALL.getId();
	
	/** */
	public UserShoppingCartSumRequest() {
	}
	
	@Override
	public void parse(HttpServletRequest request) {
		
		HttpRequestInfo requestInfo = new HttpRequestInfo(request);
		
		this.applicablePlatformId = requestInfo.getIntParameter(ApiUrlParamEnum.applicablePlatformId.getParamName(),ApplicablePlatformEnum.ALL.getId());
		this.userId = requestInfo.getIntParameter(ApiUrlParamEnum.userId.getParamName());
		this.userTraceId = requestInfo.getParameter(ApiUrlParamEnum.userTraceId.getParamName());
		if ( userId <1 && StringUtil.isEmpty(userTraceId)) {
			throw new RequestIllegalException("error userId:"+userId +" or userTraceId is null");
		}
		
		this.subApplicablePlatformId = requestInfo.getIntParameter(ApiUrlParamEnum.subApplicablePlatform.getParamName(), PromotionApplicablePlatformEnum.NEW_MALL.getId());
	}
	
	public int getUserId() {
		return userId;
	}
	
	public void setUserId(int userId) {
		this.userId = userId;
	}

	public int getApplicablePlatformId() {
		return applicablePlatformId;
	}

	public void setApplicablePlatformId(int applicablePlatformId) {
		this.applicablePlatformId = applicablePlatformId;
	}

	public String getUserTraceId() {
		return userTraceId;
	}

	public void setUserTraceId(String userTraceId) {
		this.userTraceId = userTraceId;
	}

	public int getSubApplicablePlatformId() {
		return subApplicablePlatformId;
	}

	public void setSubApplicablePlatformId(int subApplicablePlatformId) {
		this.subApplicablePlatformId = subApplicablePlatformId;
	}
	
}
